<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>

<!DOCTYPE html>
<html>
<head>
    <title>我的收藏</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <link type="text/css" rel="stylesheet" href="css/bootstrap.css">
    <link type="text/css" rel="stylesheet" href="css/style.css">
    <script type="text/javascript" src="js/jquery.min.js"></script>
    <script type="text/javascript" src="js/bootstrap.min.js"></script>
    <script type="text/javascript" src="layer/layer.js"></script>
    <script type="text/javascript" src="js/cart.js"></script>
</head>
<body>

<!--header-->
<jsp:include page="/header.jsp"></jsp:include>
<!--//header-->

<!--account-->
<div class="account">
    <div class="container">
        <div class="register">
            <c:if test="${!empty msg }">
                <div class="alert alert-success">${msg }</div>
            </c:if>
            <c:if test="${!empty failMsg }">
                <div class="alert alert-danger">${failMsg }</div>
            </c:if>
            
            <div class="register-top-grid">
                <h3>我的收藏</h3>
                
                <!-- 收藏列表内容 -->
                <div class="products">
                    <div class="container">
                        <div class="row">
                            <c:forEach items="${favoriteList}" var="f">
                                <div class="col-md-3 col-sm-6">
                                    <div class="product-grid">
                                        <a href="/goods_detail?id=${f.goodsId}">
                                            <div class="more-product"><span> </span></div>
                                            <div class="product-img b-link-stripe b-animate-go thickbox">
                                                <img src="${f.goods.cover}" class="img-responsive" alt="${f.goods.name}" width="240" height="240">
                                                <div class="b-wrapper">
                                                    <h4 class="b-animate b-from-left b-delay03">
                                                        <button class="btn btn-primary">查看详情</button>
                                                    </h4>
                                                </div>
                                            </div>
                                        </a>
                                        <div class="product-info simpleCart_shelfItem">
                                            <div class="product-info-cust">
                                                <h4>${f.goods.name}</h4>
                                                <span class="item_price">¥ ${f.goods.price}</span>
                                                <div class="clearfix"></div>
                                            </div>
                                            <div class="product-info-cust">
                                                <a class="item_add" href="javascript:;" onclick="buy(${f.goodsId})">加入购物车</a>
                                                <a class="item_del" href="javascript:;" onclick="removeFavorite(${f.id})">取消收藏</a>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </c:forEach>
                        </div>
                        
                        <!-- 如果没有收藏商品，显示提示信息 -->
                        <c:if test="${empty favoriteList}">
                            <div class="alert alert-info">您还没有收藏任何商品！</div>
                        </c:if>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<!--footer-->
<jsp:include page="/footer.jsp"></jsp:include>
<!--//footer-->

<!-- 添加收藏操作的JavaScript函数 -->
<script type="text/javascript">
    function removeFavorite(favoriteId) {
        if(confirm("确定取消收藏该商品吗？")) {
            location.href = "/favorite_delete?id=" + favoriteId;
        }
    }
</script>

</body>
</html>